﻿<%@ Page Title="Log de Errores" Language="C#" MasterPageFile="~/MasterPage.master"
	AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="ESF.Web" Namespace="ESF.Web.ServerControls" TagPrefix="esf" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="cntContents" ContentPlaceHolderID="cntContents" runat="Server">
	<asp:Panel CssClass="divForm" ID="divForm" runat="server" DefaultButton="btnBrowse">
		<div class="header">
			<div class="title">
				<asp:Label ID="lblTitle" runat="server"></asp:Label>
			</div>
			<div class="subtitle">
				Diligencie los siguientes filtros para visualizar el log de errores reportado por
				las aplicaciones, se muestra el conteo total y la última ocurrencia.<br />
			</div>
		</div>
		<div class="divField" style="width: 270px;">
			<div class="divSubField">
				<div class="label">
					Inicio
					<asp:RegularExpressionValidator ID="revtxtStartLogDate" runat="server" meta:resourcekey="revtxtStartLogDate"
						Text="*" Display="Dynamic" ValidationExpression="^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$"
						ControlToValidate="txtStartLogDate"></asp:RegularExpressionValidator>
				</div>
				<div class="field">
					<asp:TextBox ID="txtStartLogDate" runat="server" Width="80px" MaxLength="10" ToolTip="Ejemplo: 1981-10-10"></asp:TextBox>&nbsp;
					<asp:ImageButton ID="imgStartLogDate" ImageUrl="~/Images/Icons/icoCalendar.png" CausesValidation="false"
						runat="server" />
					<asp:CalendarExtender ID="txtStartLogDate_CalendarExtender" runat="server" Enabled="True"
						PopupButtonID="imgStartLogDate" TargetControlID="txtStartLogDate" Format="yyyy-MM-dd">
					</asp:CalendarExtender>
				</div>
			</div>
			<div class="divSubField">
				<div class="label">
					Fin
					<asp:RegularExpressionValidator ID="revtxtEndLogDate" runat="server" meta:resourcekey="revtxtEndLogDate"
						Text="*" Display="Dynamic" ValidationExpression="^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$"
						ControlToValidate="txtEndLogDate"></asp:RegularExpressionValidator>
				</div>
				<div class="field">
					<asp:TextBox ID="txtEndLogDate" runat="server" Width="80px" MaxLength="10" ToolTip="Ejemplo: 1981-11-10"></asp:TextBox>&nbsp;
					<asp:ImageButton ID="imgEndLogDate" ImageUrl="~/Images/Icons/icoCalendar.png" CausesValidation="false"
						runat="server" />
					<asp:CalendarExtender ID="txtEndLogDate_CalendarExtender" runat="server" Enabled="True"
						PopupButtonID="imgEndLogDate" TargetControlID="txtEndLogDate" Format="yyyy-MM-dd">
					</asp:CalendarExtender>
				</div>
			</div>
		</div>
		<div class="divField divField_half">
			<div class="label">
				Ordenar primero por</div>
			<div class="field">
				<asp:DropDownList ID="ddlOrderBy" runat="server">
					<asp:ListItem Selected="True" Value="errorLogDate" Text="Fecha de la Excepción mas reciente"></asp:ListItem>
					<asp:ListItem Value="errorCount" Text="Excepción mas ocurrida"></asp:ListItem>
				</asp:DropDownList>
			</div>
		</div>
		<div class="divField divField_half">
			<div class="label">
				Usuario
			</div>
			<div class="field">
				<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
			</div>
		</div>
		<div style="height: 40px; padding-top: 26px;">
			<asp:Button ID="btnFirstFilter" runat="server" Width="90px" Text="Filtrar" CausesValidation="false"
				OnClick="btnFirstFilter_Click" />
		</div>
		<asp:UpdatePanel ID="updFields" runat="server" UpdateMode="Conditional">
			<Triggers>
				<asp:AsyncPostBackTrigger ControlID="btnClear" />
				<asp:AsyncPostBackTrigger ControlID="btnEmptyLog" />
				<asp:AsyncPostBackTrigger ControlID="btnFirstFilter" />
			</Triggers>
			<ContentTemplate>
				<asp:Panel ID="pnlExtraFilters" runat="server" Visible="false">
					<div class="divField" style="clear: left;">
						<div class="label">
							Aplicación *
							<asp:RequiredFieldValidator ID="rfvddlApplicationName" runat="server" SetFocusOnError="true"
								Display="Dynamic" ControlToValidate="ddlApplicationName" ErrorMessage="Seleccione una Aplicación"
								Text="*"></asp:RequiredFieldValidator>
						</div>
						<div class="field">
							<asp:DropDownList ID="ddlApplicationName" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlApplicationName_SelectedIndexChanged">
							</asp:DropDownList>
						</div>
					</div>
					<div class="divField">
						<div class="label">
							Tipo de Excepción
						</div>
						<div class="field">
							<asp:DropDownList ID="ddlExceptionType" runat="server">
							</asp:DropDownList>
						</div>
					</div>
					<div class="divField divField_big">
						<div class="label">
							Mensaje
						</div>
						<div class="field">
							<asp:DropDownList ID="ddlMessage" runat="server">
							</asp:DropDownList>
						</div>
					</div>
					<div class="divField divField_big">
						<div class="label">
							Detalle del Mensaje
						</div>
						<div class="field">
							<asp:DropDownList ID="ddlDetailMessage" runat="server">
							</asp:DropDownList>
						</div>
					</div>
				</asp:Panel>
			</ContentTemplate>
		</asp:UpdatePanel>
		<div class="divOperations">
			<asp:UpdatePanel ID="updOperations" runat="server" UpdateMode="Conditional">
				<ContentTemplate>
					<asp:Button ID="btnBrowse" runat="server" Text="Consultar" OnClick="btnBrowse_Click" />
					<asp:Button ID="btnClear" runat="server" Text="Limpiar" UseSubmitBehavior="false"
						CausesValidation="false" OnClick="btnClear_Click" />
					&nbsp;&nbsp;&nbsp;&nbsp;
					<asp:Button ID="btnEmptyLog" runat="server" Text="Borrar Log" UseSubmitBehavior="false"
						CausesValidation="false" OnClick="btnEmptyLog_Click" />
					&nbsp;&nbsp;&nbsp;&nbsp;
					<asp:Button ID="btnDelete" runat="server" Text="Eliminar" UseSubmitBehavior="false"
						CausesValidation="false" OnClick="btnDelete_Click" />
					&nbsp;&nbsp;&nbsp;&nbsp;
					<asp:Button ID="btnClearUntilLastSevenDays" runat="server" Text="Dejar últimos 7 dias"
						UseSubmitBehavior="false" CausesValidation="false" OnClick="btnClearUntilLastSevenDays_Click" />
					<asp:ConfirmButtonExtender ID="btnDelete_ConfirmButtonExtender" runat="server" ConfirmText="Confirma eliminar los logs seleccionados?"
						Enabled="True" TargetControlID="btnDelete">
					</asp:ConfirmButtonExtender>
					<asp:ConfirmButtonExtender ID="btnEmpty_ConfirmButtonExtender" runat="server" ConfirmText="Confirma limpiar el log de errores?"
						Enabled="True" TargetControlID="btnEmptyLog">
					</asp:ConfirmButtonExtender>
					<asp:ConfirmButtonExtender ID="btnClearUntilLastSevenDays_ConfirmButtonExtender"
						runat="server" ConfirmText="Confirma limpiar el log y dejar solo los últimos 7 dias?"
						Enabled="True" TargetControlID="btnClearUntilLastSevenDays">
					</asp:ConfirmButtonExtender>
				</ContentTemplate>
			</asp:UpdatePanel>
		</div>
	</asp:Panel>
	<asp:UpdatePanel ID="updGrid" runat="server" UpdateMode="Conditional">
		<Triggers>
			<asp:AsyncPostBackTrigger ControlID="dpgErrors" />
			<asp:AsyncPostBackTrigger ControlID="btnBrowse" />
			<asp:AsyncPostBackTrigger ControlID="btnClear" />
			<asp:AsyncPostBackTrigger ControlID="btnDelete" />
			<asp:AsyncPostBackTrigger ControlID="btnEmptyLog" />
		</Triggers>
		<ContentTemplate>
			<esf:DataPagging ID="dpgErrors" PageSize="10" runat="server" Visible="false" OnOnPageChanged="dpgErrors_OnPageChanged" />
			<asp:GridView ID="grvErrors" AutoGenerateColumns="False" runat="server" OnRowDataBound="grvErrors_RowDataBound">
				<Columns>
					<asp:TemplateField HeaderText="Sel." ItemStyle-Width="20px">
						<HeaderTemplate>
							<asp:CheckBox ID="chkSelectAll" runat="server" AutoPostBack="true" OnCheckedChanged="chkSelectAll_CheckedChanged" />
						</HeaderTemplate>
						<ItemTemplate>
							<asp:HiddenField ID="hidItemID" runat="server" />
							<asp:CheckBox ID="chkSelect" runat="server" /><br />
							<asp:Label ID="lblErrorCount" CssClass="errorCount" runat="server"></asp:Label>
						</ItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="Última Ubicación" ItemStyle-Width="300px">
						<ItemTemplate>
							<i>Fecha: </i>
							<asp:Label ID="lblErrogLogDate" runat="server"></asp:Label><br />
							<i>Aplicación: </i>
							<asp:Label ID="lblApplicationName" runat="server"></asp:Label><br />
							<i>Código: </i>
							<asp:Label ID="lblCode" runat="server"></asp:Label><br />
							<i>Tipo: </i>
							<b><asp:Label ID="lblExceptionType" runat="server"></asp:Label></b><br />
							<i>Usuario: </i>
							<asp:Label ID="lblUserName" runat="server"></asp:Label><br />
							<i>Dominio: </i>
							<asp:Label ID="lblDomainName" runat="server"></asp:Label><br />
							<i>Custom User: </i>
							<b><asp:Label ID="lblCustomUserName" runat="server"></asp:Label></b><br />
							<i>Product Version: </i>
							<asp:Label ID="lblProductVersion" runat="server"></asp:Label><br />
							<i>Web Proxy:</i>
							<asp:Label ID="lblWebProxyAddressPort" runat="server"></asp:Label><br />
							<small><i>Maquina: </i>
								<asp:Label ID="lblMachineName" runat="server"></asp:Label><br />
								<i>Dir. Remota: </i>
								<asp:Label ID="lblRemoteMachineAddress" runat="server"></asp:Label><br />
								<i>OS Version: </i>
								<asp:Label ID="lblOSVersion" runat="server"></asp:Label><br />
								<i>Runtime Version: </i>
								<asp:Label ID="lblRuntimeVersion" runat="server"></asp:Label><br />
								<i>Dirección(es): </i>
								<br />
								<asp:Label ID="lblMachineAddress" runat="server"></asp:Label>
							</small>
						</ItemTemplate>
					</asp:TemplateField>
					<asp:TemplateField HeaderText="Últimos Detalles">
						<ItemTemplate>
							<i>Message: </i>
							<asp:TextBox TextMode="MultiLine" ID="txtMessage" Height="60px" Width="600px" runat="server"
								ReadOnly="true">
							</asp:TextBox>
							<i>Detail: </i>
							<br />
							<asp:TextBox TextMode="MultiLine" ID="txtDetail" Height="60px" Width="600px" runat="server"
								ReadOnly="true">
							</asp:TextBox>
							<i>StackTrace: </i>
							<br />
							<asp:TextBox TextMode="MultiLine" ID="txtStackTrace" Height="200px" Width="600px"
								runat="server" ReadOnly="true"></asp:TextBox>
							<i>Users with same error (in same date)</i>
							<asp:TextBox ID="txtUsersWithSameErrorAndDate" runat="server" TextMode="MultiLine" Width="600px"
								Height="40px" ReadOnly="true"></asp:TextBox>
								<br />
							<i>Users with same error:</i>
							<asp:TextBox ID="txtUsersWithSameError" runat="server" TextMode="MultiLine" Width="600px"
								Height="40px" ReadOnly="true">
							</asp:TextBox>
						</ItemTemplate>
					</asp:TemplateField>
				</Columns>
			</asp:GridView>
		</ContentTemplate>
	</asp:UpdatePanel>
</asp:Content>
